package com.hsxshop.model;

import java.util.List;

/**
 * Created by wangchongya on 17/6/27.
 */
public class Pagination {

    private int pageIndex;
    private int pageSize;
    private int allRows;
    private int pageCounts;
    private List<Object> list;
    public Pagination(){
        this.pageIndex=1;
        this.pageSize=10;
    }

    public Pagination(int pageIndex,int pageSize){
        this.pageIndex=pageIndex<=0 ? 1 : pageIndex;
        this.pageSize=pageSize;
    }
    /**
     * 得到当前页是第几页
     * @return
     */
    public int getPageIndex() {
        return pageIndex;
    }
    /**
     * 设置当前页是第几页
     * @param pageIndex
     */
    public void setPageIndex(int pageIndex) {
        this.pageIndex = pageIndex;
    }
    /**
     * 得到页大小
     * @return
     */
    public int getPageSize() {
        return pageSize;
    }
    /**
     * 设置页大小
     * @param pageSize
     */
    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }
    /**
     * 设置总页数
     * @return
     * @throws Exception
     */
    public void setPageCounts(){
        if (allRows%pageSize==0) {
            this.pageCounts=allRows/pageSize;

        }else {
            this.pageCounts=allRows/pageSize+1;
        }
    }
    /**
     * 得到总页数
     * @return
     */
    public int getPageCounts(){
        return this.pageCounts;
    }
    /**
     * 得到总行数
     * @return
     */
    public int getAllRows() {
        return allRows;
    }
    /**
     * 设置总行数
     * @param allRows
     */
    public void setAllRows(int allRows) {
        this.allRows = allRows;
    }
    /**
     * 得到分页记录集合
     * @return
     */
    public List<Object> getList() {
        return list;
    }
    /**
     * 设置分页记录集合
     * @param list
     */
    public void setList(List<Object> list) {
        this.list = list;
    }


}
